function urlencode(host,params){
    let result="http://"+host;
    let arr=[];
    for(key of Object.keys(params)){
        arr.push(key+'='+params[key]);
    }
    if(arr.length>0){
        result+="?"+arr.join("&");
    }
    return result;
}

console.log(urlencode("localhost",{
    name:'zs',
    age:20
}));